package com.io.example.demoparent.controller;

import com.io.example.demoparent.service.impl.QueryGrantTypeService;
import com.io.example.demoparent.service.impl.RedPaperStrategy;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 策略模式-优惠卷发放控制器
 *
 * @program: demo-project
 * @ClassName GrantTypeController
 * @description:
 * @author: 宠儿
 * @create: 2024−09-01 15:09
 * @Version 1.0
 **/
@RestController
public class GrantTypeController {

    @Resource
    private QueryGrantTypeService queryGrantTypeService;

    @Resource
    private RedPaperStrategy redPaperStrategy;

    @PostMapping("/grantType")
    public String test(String resourceName, String resourceId) {
        return queryGrantTypeService.getResult(resourceName, resourceId);
    }

    /**
     * 传统模式
     */
    @PostMapping("/grantType2")
    public String test2(String resourceName, String resourceId) {
        return redPaperStrategy.query(resourceId);
    }
}
